package com.jams.goodox.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jams.goodox.R;
import com.jams.goodox.entity.PointRecord;

import java.util.List;

/**
 * Created by Jin on 2016/5/17.
 * Description 积分使用记录适配器
 */
public class PointRecordAdapter extends BaseQuickAdapter<PointRecord.DataBean.ResultListBean> {

	private Context context;

	public PointRecordAdapter(Context context, List<PointRecord.DataBean.ResultListBean> list) {
		super(R.layout.mine_points_record_listview, list);
		this.context = context;
	}

	@Override
	protected void convert(BaseViewHolder baseViewHolder, PointRecord.DataBean.ResultListBean resultListBean) {
		baseViewHolder.setText(R.id.remark, resultListBean.getRemark())
				.setText(R.id.intime, resultListBean.getIntime())
				.setVisible(R.id.right_arrow, resultListBean.getType() == 1 && notNull(resultListBean.getRedeemId()))
				.setText(R.id.intNum, resultListBean.getType() == 0 ? "+" + resultListBean.getIntNum() : "-" + resultListBean.getIntNum())
				.setTextColor(R.id.intNum, resultListBean.getType() == 0
						? ContextCompat.getColor(context, R.color.orange)
						: ContextCompat.getColor(context, R.color.font_hint));
	}

	private boolean notNull(String id) {
		return id != null && !id.equalsIgnoreCase("");
	}
}
